package com.whp02.annotation.circle.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author wanghp
 * @version 1.0
 * @description: TODO
 * @date 2021/1/27 16:22
 */
@Aspect
@Component
public class AspectConfig {

//	@Pointcut("execution(* com.whp02.annotation.circle.aop.LogService.*(..))")

	@Pointcut("@annotation(com.whp02.annotation.circle.aop.Log)")
	public void pointCut() {
	}

	@Before("pointCut()")
	public void before() {
		System.out.println("enter before");
	}

	@Around("pointCut()")
	public void around(ProceedingJoinPoint joinPoint) throws Throwable {
		long start = System.currentTimeMillis();
		System.out.println("进入around");
		joinPoint.proceed();
		System.out.println("around调用用户方法执行完毕！！！！");
		long end = System.currentTimeMillis();
//		System.out.println(String.format("执行花费:%s毫秒", end - start));
	}

	@After("pointCut()")
	public void after() {
		System.out.println("enter after");
	}

	@AfterReturning("pointCut()")
	public void afterReturning() {
		System.out.println("enter afterReturning");
	}

	@AfterThrowing("pointCut()")
	public void AfterThrowing() {
		System.out.println("enter AfterThrowing");
	}
}
